﻿using Core.Framework.Model.Common;
using Microsoft.AspNetCore.Builder;

namespace Core.Middleware.DynamicApi
{
    public static class UseDynamicApi
    {
        /// <summary>
        /// 启用动态API
        /// </summary>
        /// <param name="applicationBuilder"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseDynamicApiMidWare(this IApplicationBuilder applicationBuilder)
        {

            if (CoreStartupHelper.GetConfigValue("Service:DynamicApi") == "True")
            {
                return applicationBuilder.UseMiddleware<DynamicApiMidWare>();
            }
            else
            {
                return applicationBuilder;
            }

            
        }

    }
}
